//
//  MDHKeyedSubscript.swift
//  MDHPT
//
//  Created by 高得华 on 2019/5/13.
//  Copyright © 2019年 高得华. All rights reserved.
///  参数

import UIKit

open class MDHKeyedSubscript: NSObject {
    /// 字典
    @objc public var kvs = [String: Any]()
    
    /// 类方法
    @objc public class func subscriptWithDictionary(dict: [String: Any] = [String: Any]()) -> MDHKeyedSubscript {
        return MDHKeyedSubscript(dict: dict)
    }
    @objc convenience init(dict: [String: Any] = [String: Any]()) {
        self.init()
        if dict.count > 0 {
            self.kvs = dict
        }
    }
    override init() {
        super.init()
    }
    @objc func objectForKeyedSubscript(key: String) -> Any {
        return self.kvs[key] ?? ""
    }
    @objc func setObject(obj: Any?, key: String) -> () {
        if key.count > 0 {
            if obj != nil {
                self.kvs[key] = obj
            }else{
                self.kvs.removeValue(forKey: key)
            }
        }
    }
}
